package com.example.zyh.controller;


import com.example.zyh.pojo.Loudong;
import com.example.zyh.service.LdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("/Ld")
public class LdController {
    @Autowired
    private LdService ldService;

    @RequestMapping("/list")
    public List<Loudong> select(){
        return ldService.select();
    }
    @RequestMapping("/add")
    public void add(Loudong loudong){
        ldService.addLd(loudong);
    }
    @RequestMapping("/delete")
    public void del(int id){
        ldService.delete(id);
    }

    @RequestMapping("/update")
    public void update(Loudong loudong){
        ldService.update(loudong);
    }
    @RequestMapping("/selectlike")
    public List<Loudong> selectlike(Loudong loudong){
        if(loudong.getLocation() == null){
            loudong.setLocation("");
        }
        if(loudong.getLno() == null){
            loudong.setLno("");
        }
        if (loudong.getLnumber()==null){
            loudong.setLnumber("");
        }
        if (loudong.getTotal()==null){
            loudong.setTotal("");
        }
        if(loudong.getNote()==null){
            loudong.setNote("");
        }
        return ldService.selectlike(loudong);
    }

}
